package code.part08_Net;

import org.junit.jupiter.api.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author: ZJT
 * @Time: 2021/8/1
 * @Description: IP地址类
 */
public class P01_InetAddress {

    @Test
    public void inetAddress() throws UnknownHostException {

        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost);

        InetAddress inetAdd = InetAddress.getByName("www.baidu.com");
        System.out.println(inetAdd);
        System.out.println(inetAdd.getHostAddress());
        System.out.println(inetAdd.getHostName());

    }
}
